#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require "#{LKP_SRC}/lib/string_ext"

stats = {}
while (line = $stdin.gets)
  line = line.resolve_invalid_bytes

  case line
  when /^### (\w+_\d+):$/
    item = Regexp.last_match[1]
    stats[item] = '' unless stats.key?(item)
  when /^(\w+_\d+): (fail|pass|skip|ignored_by_lkp)$/
    item = Regexp.last_match[1]
    result = Regexp.last_match[2]
    stats[item] = "#{result}: 1" unless stats.key?(item) && !stats[item].empty?
  end

end

stats.each do |k, v|
  if v.empty?
    puts "#{k}.skip: 1"
  else
    puts "#{k}.#{v}"
  end
end
